package com.opcode.nebulamobil.utility;

import java.util.Timer;
import java.util.TimerTask;

import com.opcode.nebulamobil.base.interfaces.TimerListener;


public class TimerBase extends TimerTask{

	private Timer timer;
	private TimerListener timerListener;
	
	public TimerBase(TimerListener timerListener){
		this.timer=new Timer();
		this.timerListener=timerListener;
	}
	
	public void schedule(long delay){
		this.timer.schedule(this, delay);
	}
	
	public void cancelTimer(){
		this.timer.cancel();
		this.timer.purge();
	}
	
	@Override
	public void run() {
		timerListener.timeFinished();
	}

}
